翻訳と辞書
Words near each other
・ Urairat Soimee
・ Uraiyur
・ Uraiújfalu
・ Urajärvi
・ Urak Gate
・ Urak Lawoi’ language
・ Uquian
・ Uquiasaurus
・ Uquía (Jujuy)
・ UR
・ Ur
・ Ur (continent)
・ Ur (cuneiform)
・ UR (My Love)
・ Ur (novella)
Ur (programming language)
・ Ur (root)
・ Ur (rune)
・ UR Almería
・ UR Chicago
・ Ur Cool
・ UR G class
・ UR GB class
・ UR GC class
・ UR GD class
・ Ur jordens djup
・ Ur Kaśdim
・ UR La Louvière Centre
・ UR MS class
・ UR Namur


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Ur (programming language) : ウィキペディア英語版
Ur (programming language)

Ur also called Ur/Web is an open source functional programming language specific for web development, created by Adam Chlipala at the Massachusetts Institute of Technology that from a single program produces server code, browser client code and SQL code specific for the chosen database backend.
Ur supports a powerful kind of metaprogramming based on row types.〔
Ur/Web is Ur plus a special standard library and associated rules for parsing and optimization. Ur/Web supports construction of dynamic web applications backed by SQL databases. The signature of the standard library is such that well-typed Ur/Web programs "don't go wrong" in a very broad sense. Not only do they not crash during particular page generations, but they also may not:〔
* Suffer from any kinds of code injection attacks
* Return invalid HTML
* Contain dead intra-application links
* Have mismatches between HTML forms and the fields expected by their handlers
* Include client-side code that makes incorrect assumptions about the "AJAX"-style services that the remote web server provides
* Attempt invalid SQL queries
* Use improper marshaling or unmarshaling in communication with SQL databases or between browsers and web servers
This type safety is just the foundation of the Ur/Web methodology. It is also possible to use metaprogramming to build significant application pieces by analysis of type structure.〔
The Ur/Web compiler also produces very efficient object code that does not use garbage collection.〔
The implementation of all this is open source.〔
SQL syntax templates embedded in the language facilitate the handling of tables.
Although the syntax is based on Standard ML the language includes concepts from Haskell with additional type manipulation.
Ajax call/response is serialized through a monad called ''transaction'' (corresponds to Haskell's IO) and its marshalling and decoding is encapsulated in the ''rpc'' function.
The browser client side includes functional reactive programming facilities using the ''(source a)'' type and a ''signal monad''.

>> Ur/Web not only makes web applications easier to write, it also makes them more secure.
>> "Let's say you want to have a calendar widget on your web page, and you're going to use a library that provides the calendar widget, and on the same page there's also an advertisement box that's based on code that's provided by the ad network," Chlipala said.〔
>> "What you don't want is for the ad network to be able to change how the calendar works or the author of the calendar code to be able to interfere with delivering the ads."〔

== Example program ==

This is a demo program showing client, server and database code with Ajax communication, from the web demos,〔(Ur language demo programs )〕 with extra comments to outline each of the components:
Interface file (ML-like signature) with .urs extension:

(
* the environment monad is called transaction, corresponds to Haskell's IO monad
*)
val main : unit -> transaction page

Implementation file (.ur extension):

datatype list t = Nil | Cons of t
* list t
table t :
PRIMARY KEY Id
(
* server side database access, called through AJAX XmlHttpRequest
encapsulated as ''rpc'' function (remote procedure call)
*)
fun add id s =
(
* sql dml template with
*)
dml (INSERT INTO t (Id, A) VALUES (, ))
fun del id =
dml (DELETE FROM t WHERE t.Id = )
fun lookup id =
(
* haskell style monadic code
*)
ro <- oneOrNoRows (SELECT t.A FROM t WHERE t.Id = );
case ro of
None => return None (
* return is the ''monad'' lifting function
*)
| Some r => return (Some r.T.A)
(
* ''check'' called by client side onClick event handler,
so it will be compiled to JavaScript as page embedded client script
*)
fun check ls =
case ls of
Nil => return ()
| Cons (id, ls') =>
ao <- rpc (lookup id); (
* Ajax call to server side
*)
alert (case ao of
None => "Nada"
| Some a => a
);
check ls'
fun main () =
idAdd <- source "";
aAdd <- source "";
idDel <- source "";
(
* generates web page with JavaScript inclusions
*)
return